
/**
 * Date:2019年6月5日下午2:50:02
 * Copyright (c) 2019, www.bwbroad.com All Rights Reserved.
 *
*/

package com.xue.im.common.vo;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Description: TODO <br/>
 * Date: 2019年6月5日 下午2:50:02 <br/>
 * 
 * @author xuejianxin
 */
public class User implements Comparator<User>, Serializable {
	private static final long serialVersionUID = -5322805037131480039L;
	private String userid;
	private String username;
	private String password;
	private String ip;
	private int sex;
	private int status;// 0 下线,1 在线,2 重复登录,3密码不对,4用户不存在
	private transient int msgCount = 0;

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	

	@Override
	public String toString() {
		return String.format("User [userid=%s, username=%s, ip=%s, sex=%s, status=%s]", userid, username, ip, sex,
				status);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((userid == null) ? 0 : userid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (userid == null) {
			if (other.userid != null)
				return false;
		} else if (!userid.equals(other.userid))
			return false;
		return true;
	}

	@Override
	public int compare(User o1, User o2) {
		return o1.getUserid().compareTo(o2.getUserid());
	}

	public int getMsgCount() {
		return msgCount;
	}

	public void addMsgCount() {
		this.msgCount++;
	}

	public void clearMsgCount() {
		this.msgCount = 0;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

}
